import Vue from 'vue'
import App from './App'

import store from './store'
import cuCustom from './static/colorui/components/cu-custom.vue'
Vue.component('cu-custom',cuCustom);

Vue.config.productionTip = false
/**
 * get请求的封装 
 */
const reqGet=(params)=>{
	var baseUrl=undefined;
	if(params.url.includes("menu")){
		 baseUrl = "http://localhost:8087/";
	}else if(params.url.includes("user")){
		 baseUrl = "http://localhost:8090/";
	}else if(params.url.includes("lecturer") || 
			 params.url.includes("works") || 
			 params.url.includes("comments") ||
			 params.url.includes("lecturerapply")||
			 params.url.includes("column")){
		 baseUrl = "http://localhost:8085/";
	}else if(params.url.includes("home")){
		 baseUrl = "http://localhost:8070/"
	}
	return new Promise(resolve=>{
		uni.request({
			...params,
			url:baseUrl+params.url,
			method:"GET",
			success: (res) => {
				resolve(res.data);
			}
		})
	})
}
/**
 * post请求的封装 
 */
const reqPost=(params)=>{
	var baseUrl=undefined;
	if(params.url.includes("menu")){
		 baseUrl = "http://localhost:8087/";
	}else if(params.url.includes("user")){
		 baseUrl = "http://localhost:8090/";
	}else if(params.url.includes("lecturer") || 
			 params.url.includes("works")|| 
			 params.url.includes("comments") || 
			 params.url.includes("lecturerapply") || 
			 params.url.includes("column")){
		baseUrl = "http://localhost:8085/";
	}else if(params.url.includes("home")){
		 baseUrl = "http://localhost:8070/"
	}
	return new Promise(resolve=>{
		uni.request({
			...params,
			url:baseUrl+params.url,
			method:"POST",
			params:params.data,
			success: (res) => {
				resolve(res.data);
			}
		})
	})
}
Vue.prototype.$api = { reqGet,reqPost};



Vue.prototype.$store = store;

App.mpType = 'app'

const app = new Vue({
	store,
    ...App
})
app.$mount()
